#Boa:Dialog:Dialog1

import wx

def create(parent, app ):
    return Dialog1(parent, app )

[wxID_DIALOG1, wxID_DIALOG1BUTTONCLOSE, wxID_DIALOG1BUTTONCONNECT, 
 wxID_DIALOG1STATICTEXT1, wxID_DIALOG1STATICTEXT2, wxID_DIALOG1TEXTCTRLHOST, 
 wxID_DIALOG1TEXTCTRLPORT, 
] = [wx.NewId() for _init_ctrls in range(7)]

class Dialog1(wx.Dialog):
    def _init_coll_flexGridSizerHostPort_Items(self, parent):
        # generated method, don't edit

        parent.AddWindow(self.staticText1, 0, border=5, flag=wx.ALL)
        parent.AddWindow(self.textCtrlHost, 0, border=5, flag=wx.ALL)
        parent.AddWindow(self.staticText2, 0, border=5, flag=wx.ALL)
        parent.AddWindow(self.textCtrlPort, 1, border=5, flag=wx.ALL)

    def _init_coll_boxSizerMain_Items(self, parent):
        # generated method, don't edit

        parent.AddSizer(self.flexGridSizerHostPort, 1, border=5, flag=wx.ALL)

    def _init_coll_flexGridSizerHostPort_Growables(self, parent):
        # generated method, don't edit

        parent.AddGrowableCol(1)

    def _init_sizers(self):
        # generated method, don't edit
        self.boxSizerMain = wx.BoxSizer(orient=wx.VERTICAL)

        self.flexGridSizerHostPort = wx.FlexGridSizer(cols=2, hgap=5, rows=2,
              vgap=5)

        self._init_coll_boxSizerMain_Items(self.boxSizerMain)
        self._init_coll_flexGridSizerHostPort_Growables(self.flexGridSizerHostPort)
        self._init_coll_flexGridSizerHostPort_Items(self.flexGridSizerHostPort)

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_DIALOG1, name='', parent=prnt,
              pos=wx.Point(407, 288), size=wx.Size(210, 140),
              style=wx.DEFAULT_DIALOG_STYLE, title=u'SeaBattle v 0.01')
        self.SetClientSize(wx.Size(202, 113))
        self.Center(wx.BOTH)
        self.Bind(wx.EVT_CLOSE, self.OnButtonCloseButton)

        self.staticText1 = wx.StaticText(id=wxID_DIALOG1STATICTEXT1,
              label=u'&Host', name='staticText1', parent=self, pos=wx.Point(10,
              10), size=wx.Size(29, 13), style=0)

        self.textCtrlHost = wx.TextCtrl(id=wxID_DIALOG1TEXTCTRLHOST,
              name=u'textCtrlHost', parent=self, pos=wx.Point(54, 10),
              size=wx.Size(138, 21), style=0, value=u'localhost')

        self.staticText2 = wx.StaticText(id=wxID_DIALOG1STATICTEXT2,
              label=u'Port', name='staticText2', parent=self, pos=wx.Point(10,
              46), size=wx.Size(20, 13), style=0)

        self.textCtrlPort = wx.TextCtrl(id=wxID_DIALOG1TEXTCTRLPORT,
              name=u'textCtrlPort', parent=self, pos=wx.Point(54, 46),
              size=wx.Size(138, 21), style=0, value=u'18000')

        self.buttonConnect = wx.Button(id=wxID_DIALOG1BUTTONCONNECT,
              label=u'Connect', name=u'buttonConnect', parent=self,
              pos=wx.Point(24, 80), size=wx.Size(75, 23), style=0)
        self.buttonConnect.Bind(wx.EVT_BUTTON, self.OnButtonConnectButton,
              id=wxID_DIALOG1BUTTONCONNECT)

        self.buttonClose = wx.Button(id=wxID_DIALOG1BUTTONCLOSE, label=u'Close',
              name=u'buttonClose', parent=self, pos=wx.Point(104, 80),
              size=wx.Size(75, 23), style=0)
        self.buttonClose.Bind(wx.EVT_BUTTON, self.OnButtonCloseButton,
              id=wxID_DIALOG1BUTTONCLOSE)

        self._init_sizers()

    def __init__(self, parent , app ):
        self._init_ctrls(parent)
        self.app = app

    def OnButtonConnectButton(self, event):
        host = self.textCtrlHost.GetValue()
        port = self.textCtrlPort.GetValue()
        if( self.app.server_proxy.connect( host , port ) ):
            self.EndModal(1)

    def OnButtonCloseButton(self, event):
        self.EndModal(0)
